-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CNF-14679: Adapt to single H/W manager plugin #220
Conversation
@tliu2021: This pull request references CNF-14679 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Makefile
Outdated
@@ -170,7 +173,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified | |||
.PHONY: deploy | |||
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. | |||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | |||
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f - | |||
$(KUSTOMIZE) build config/default | sed 's|\plugin-namespace-placeholder|$(HWMGR_PLUGIN_NAMESPACE)|g' | $(KUBECTL) apply -f - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a common method for doing such customizations? TALM sets a number of env variables by creating a patch.yaml that gets applied by the kustomization.yaml:
https://github.com/openshift-kni/cluster-group-upgrades-operator/blob/main/Makefile#L268
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if the TALM approach is the best option. I'll investigate further to see if there's a better way to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kustomize in FluxCD (kustomize.toolkit.fluxcd.io) supports post-build variable substitution, but I don't think it's necessary to introduce that feature just for this. Instead, I'm using a ConfigMap to pass the environment variable to the deployment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just seemed like TALM's method of creating a patch with env vars is a little more formal than doing a sed to modify the output of the kustomize build while piping to the apply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I believe using a ConfigMap with Kustomize Replacements is also a solid solution for this use case.
// GetHwMgrPluginNS returns the value of environment variable HWMGR_PLUGIN_NAMESPACE | ||
func GetHwMgrPluginNS() string { | ||
// Ensure that this code only runs once | ||
once.Do(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This once.Do
is new to me... Very cool!
@@ -42,6 +42,9 @@ type NodePoolSpec struct { | |||
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Location Spec",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} | |||
LocationSpec `json:",inline"` | |||
|
|||
// HwMgrId is the identifier for the hardware manager plugin adaptor. | |||
HwMgrId string `json:"hwMgrId" yaml:"hwMgrId"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks the current plugin code, as it is adding a new required field. I think add omitempty
here may avoid that. We can likely drop the omitempty
later once the plugin is updated to know about the new field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified that adding omitempty
allows the current plugin code to work, which is referencing the previous version of the CRD, which it causes a failure to update the CR without it, as it would be missing this new field.
HwMgrId string `json:"hwMgrId" yaml:"hwMgrId"` | |
HwMgrId string `json:"hwMgrId,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, need to support the current plugin code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
@@ -42,6 +42,9 @@ type NodePoolSpec struct { | |||
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Location Spec",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"} | |||
LocationSpec `json:",inline"` | |||
|
|||
// HwMgrId is the identifier for the hardware manager plugin adaptor. | |||
HwMgrId string `json:"hwMgrId" yaml:"hwMgrId"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the yaml
field necessary? The code seems inconsistent about using it. It's there for some fields, but not all. If it's not needed, if the yaml would default to the json field, we should drop it altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The yaml field is not needed and it will be removed.
/retest |
/lgtm |
/retest |
Makefile
Outdated
if [ "$(OS)" = "darwin" ]; then \ | ||
curl -LO "https://dl.k8s.io/release/$$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/$(ARCH)/kubectl"; \ | ||
else \ | ||
curl -LO "https://dl.k8s.io/release/$$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(ARCH)/kubectl"; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use a fixed version here and just always use kubectl from LOCALBIN. The Makefile has the ENVTEST_K8S_VERSION version from the original operator-sdk setup, I believe, but the envtest bits have been removed. It might be a bit nicer codewise to use it, actually, as it will handle the arch for us. You can see an example in the plugin Makefile:
https://github.com/openshift-kni/oran-hwmgr-plugin/blob/main/Makefile#L120
It downloads the latest setup-envtest binary with the envtest target, which is then used to download kubectl and return its path.
For example:
dpenney ~/testing/envtest $ mkdir bin
dpenney ~/testing/envtest $ LOCALBIN=$PWD/bin
dpenney ~/testing/envtest $ GOBIN=$LOCALBIN go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
go: downloading sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240927101401-4381fa0aeee4
dpenney ~/testing/envtest $ find bin
bin
bin/setup-envtest
dpenney ~/testing/envtest $ bin/setup-envtest use 1.28.3 --bin-dir $LOCALBIN -p path
/home/dpenney/testing/envtest/bin/k8s/1.28.3-linux-amd64
dpenney ~/testing/envtest $ find bin
bin
bin/setup-envtest
bin/k8s
bin/k8s/1.28.3-linux-amd64
bin/k8s/1.28.3-linux-amd64/etcd
bin/k8s/1.28.3-linux-amd64/kube-apiserver
bin/k8s/1.28.3-linux-amd64/kubectl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Makefile has been updated.
/retest |
Signed-off-by: Tao Liu <tali@redhat.com>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: donpenney The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This update introduces the following changes:
Note: To continue using the test plugin, use the following commands:
make run HWMGR_PLUGIN_NAMESPACE=oran-hwmgr-plugin-test
make deploy HWMGR_PLUGIN_NAMESPACE=oran-hwmgr-plugin-test